using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace CincinnatiLibraryCheckAvailability
{
    [Flags]
    public enum KeyMod
    {
        None = 0,
        Alt = 1,
        Control = 2,
        Shift = 4,
        Win = 8
    }

    [Serializable]
    public class HotKey
    {
        public Keys Key;
        public KeyMod Modifiers;
        public IntPtr Handle;
        public short id=0;

        public HotKey(Keys key, KeyMod modifiers,IntPtr handle)
        {
            this.Key = key;
            this.Modifiers = modifiers;
            this.Handle = handle;
        }

        public HotKey(SerializationInfo info, StreamingContext ctxt)
        {
            Key = (Keys)info.GetValue("Key", typeof(Keys));
            Modifiers = (KeyMod)info.GetValue("Modifiers", typeof(KeyMod));
            id = (short)info.GetValue("id", typeof(short));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            //You can use any custom name for your name-value pair. But make sure you
            // read the values with the same name. For ex:- If you write EmpId as "EmployeeId"
            // then you should read the same with "EmployeeId"
            info.AddValue("Key", Key);
            info.AddValue("Modifiers", Modifiers);
            info.AddValue("id", id);
        }

        public override string ToString()
        {
            if (Modifiers == KeyMod.None)
                return Key.ToString();
            return "<"+Modifiers.ToString().Replace(", ","> + <")+"> + " + Key.ToString();
        }
    }
}
